<?php /* Smarty version 2.6.18, created on 2010-01-26 12:20:36
         compiled from emailMessages.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'cycle', 'emailMessages.tpl', 119, false),)), $this); ?>
<div id="blanket" style="display:none; z-index: 800;"></div>
<div id="readMessage" style="background-color:#fff;width:500px;z-index: 900;display:none;position: absolute;">
</div>
<div id="newMessage" style="background-color:#fff;width:500px;z-index: 900;display:none;position: absolute;">
</div>
<script>	
	var dd = new ekimo_drag_region("content","editMessage");
</script>
<script type="text/javascript">	
	<?php echo '
		Calendar.setup({
	        inputField     :    "cal[date_sent_from]",     // id of the input field
	        ifFormat       :    "%Y-%m-%d" ,    // format of the input field
	        displayArea    :    "date_sent_from",
	        daFormat       :    "%Y-%m-%d",      // format of the display area
	        button         :    "f_trigger_c1",  // trigger for the calendar (button ID)
	        align          :    "Bl",           // alignment (defaults to "Bl")
	        singleClick    :    true,
			//onUpdate	   :    endDateChanged, //event to call after calendar is closed
	        weekNumbers    :    false,
	        zIndex		   :	2000
	    });
	'; ?>

	<?php echo '
		Calendar.setup({
	        inputField     :    "cal[date_sent_to]",     // id of the input field
	        ifFormat       :    "%Y-%m-%d" ,    // format of the input field
	        displayArea    :    "date_sent_to",
	        daFormat       :    "%Y-%m-%d",      // format of the display area
	        button         :    "f_trigger_c2",  // trigger for the calendar (button ID)
	        align          :    "Bl",           // alignment (defaults to "Bl")
	        singleClick    :    true,
			//onUpdate	   :    endDateChanged, //event to call after calendar is closed
	        weekNumbers    :    false,
	        zIndex		   :	2000
	    });
	'; ?>

</script>
<div id="main_content">
    	<h1>Messages</h1>
        
			<div class="blue">
        	    <form action="" id="filterForm" >
        	        <table style="width: 100%">
        				<tr>
        					<td nowrap><label for="filter">Show Message:</label></td>
        					<td nowrap><select name="user[type]" onchange="getMessageView(this.value);" >
        						<option value="2" selected>Received</option>				
        						<option value="1">Sent</option>
        					</select>:&nbsp;&nbsp;
        					</td>
        					<td id=messageview  width="100%">
        						<select name="user[mail]" onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))" >
        						<option value=""><?php if ($this->_tpl_vars['userType'] == 1): ?>All Recipients<?php else: ?>All Senders<?php endif; ?></option>
        						<?php $_from = $this->_tpl_vars['owners']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['owner']):
?>
        							<option value="<?php echo $this->_tpl_vars['owner']['org_id']; ?>
"><?php echo $this->_tpl_vars['owner']['name']; ?>
</option>
        						<?php endforeach; endif; unset($_from); ?>
        						</select>
        					</td>
        				</tr>
        				<tr>
        					<td><label for="filter">Status:</label></td>
        					<td colspan="2"><select name="user[read_status]" onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))">
        						<option value="2" selected>Unread Only</option>				
        						<option value="">All</option>	
        						<option value="1">Read Only</option>
        					</select></td>
        				</tr>
        				<!-- <tr>
        	                <td nowrap><label for="filter">Send Date From:</label></td>
        	                <td colspan="2">
        						<input name="user[date_sent_from]" type="text" size="10" onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))" />&nbsp;&nbsp;&nbsp;to:&nbsp;
        						<input name="user[date_sent_to]" type="text" size="10" onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))" />
        	                </td>
        	            </tr> -->
        	            <tr>
        	                <td style="width: 100px" nowrap><label for="filter">Send Date From:</label></td>
        	                <td nowrap>
        						<input style="float:left" type="hidden" name="user[date_sent_from]" id="cal[date_sent_from]" size="10"  onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))"/>
								<span id="date_sent_from"  style="width:80px; display:block; float:left; height:15px; text-align:center;"></span>
								<input style="float:left" type="image" src="/app/default/www/images/calendar.jpg" align="absmiddle" id="f_trigger_c1" style="cursor: pointer; border: 0px ;" title="Date selector"/>
								<input type="hidden" name="dateYui" value="cal[date_sent_from]/date_sent_from/f_trigger_c1">
						</tr>
						<tr>
							<td style="width: 100px" nowrap><label for="filter">Send Date To:</label></td>
							<td nowrap><input style="float:left" type="hidden" name="user[date_sent_to]" id="cal[date_sent_to]" size="10"  onchange="doajaxAction('/account/emailMessage/reload/1',1,'result',document.getElementById('filterForm'))"/>
								<span id="date_sent_to"  style="width:80px; display:block; float:left; height:15px; text-align:center;"></span>
								<input style="float:left" type="image" src="/app/default/www/images/calendar.jpg" align="absmiddle" id="f_trigger_c2" style="cursor: pointer; border: 0px ;" title="Date selector"/>
								<input type="hidden" name="dateYui" value="cal[date_sent_to]/date_sent_to/f_trigger_c2">
        	                </td>
        	            </tr>
        	            <tr align="right">
        					<td style="width: 100px" colspan="3">
								<input type="button" value="New Message" onclick="newMessage(0);"/>
        					</td>
        	            </tr>
        	        </table>
        	    </form>
        	</div>

            <div id="result">
				<div>
					<table border="0" width="100%">
						<tr><td colspan="6"><hr></td></tr>
						<tr>
							<td align="center">Read</td>
							<td align="center">Delete</td>
							<td align="right">Date Sent</td>
						<?php if ($this->_tpl_vars['userType'] == 1): ?>
							<td>Recipients</td>	
						<?php else: ?>
							<td>Sender</td>
						<?php endif; ?>
							<td width="20%">Subject</td>
							<td width="50%">Message</td>
						</tr>
						<tr><td colspan="6"><hr></td></tr>
					<?php $_from = $this->_tpl_vars['messages']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['message']):
?>
						<tr class="<?php echo smarty_function_cycle(array('values' => 'blue,notify'), $this);?>
">
							<td align="center"><input type="checkbox" name="user[read_mail]" <?php if ($this->_tpl_vars['message']['read'] == '1'): ?> CHECKED <?php endif; ?> onchange="setReadMessage('<?php echo $this->_tpl_vars['message']['message_id']; ?>
');" <?php if ($this->_tpl_vars['userType'] == 1): ?>disabled<?php endif; ?> /></td>
							<td align="center"><input type="checkbox" name="user[cancel_mail]" onchange="setCancelMessage('<?php echo $this->_tpl_vars['message']['message_id']; ?>
');" /></td>
							<td align="right" nowrap><?php echo $this->_tpl_vars['message']['date_sent']; ?>
</td>
							<?php if ($this->_tpl_vars['userType'] == 1): ?>
								<td nowrap><?php echo $this->_tpl_vars['message']['rec_name']; ?>
</td>
							<?php else: ?>
								<td nowrap><?php echo $this->_tpl_vars['message']['src_name']; ?>
</td>
							<?php endif; ?>
							<td><a href="javascript:void(0);" onclick="readMessage('<?php echo $this->_tpl_vars['message']['message_id']; ?>
','<?php echo $this->_tpl_vars['userType']; ?>
');"><?php echo $this->_tpl_vars['message']['subject']; ?>
</a></td>
							<td><?php echo $this->_tpl_vars['message']['message_part']; ?>
</td>
						</tr>
					<?php endforeach; endif; unset($_from); ?>
					</table>
				</div>
            </div><!-- results -->

</div>
<script language="javascript">
<?php echo '
	function readMessage(messageId,viewType){
		doajaxAction("/account/readMessage/messageId/"+messageId+"/viewType/"+viewType,0,\'readMessage\');
		popup("readMessage");
	}
	function newMessage(){
		doajaxAction("/account/newMessage/",0,\'newMessage\');
		popup("newMessage");
	}
	function setReadMessage(messageId,user){
		doajaxAction("/account/setReadMessage/reload/1/messageId/"+messageId,1,"result",document.getElementById("filterForm"));
	}
	function setCancelMessage(messageId,user){
		doajaxAction("/account/setCancelMessage/reload/1/messageId/"+messageId,1,"result",document.getElementById("filterForm"));
	}
	function getMessageView(filter){
		doajaxAction("/account/getMessageView/view_type/"+filter,0,"messageview");
		doajaxAction("/account/emailMessage/reload/1/view_type/"+filter,1,"result",document.getElementById("filterForm"));
	}
'; ?>

</script>